package io.finer.erp.jeecg.stock.service;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

import io.finer.erp.jeecg.bas.vo.PrintProductVO;
import io.finer.erp.jeecg.finance.dto.CustomerGrossDetailDTO;
import io.finer.erp.jeecg.finance.dto.CustomerGrossProfitDTO;
import io.finer.erp.jeecg.finance.dto.GrossProfitDetailDTO;
import io.finer.erp.jeecg.finance.dto.GrossProfitSummaryDTO;
import io.finer.erp.jeecg.stock.vo.FreightOrIoBillVo;
import io.finer.erp.jeecg.stock.vo.StkIoBillVO;

import org.apache.ibatis.annotations.Param;
import org.jeecg.common.api.vo.Result;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;

import io.finer.erp.jeecg.stock.dto.StkEntryDetailDTO;
import io.finer.erp.jeecg.stock.dto.StkPurchaseOrderDTO;
import io.finer.erp.jeecg.stock.entity.StkCheckBill;
import io.finer.erp.jeecg.stock.entity.StkCheckBillEntry;
import io.finer.erp.jeecg.stock.entity.StkIoBill;
import io.finer.erp.jeecg.stock.entity.StkIoBillEntry;

/**
 * @Description: 出入库单
 * @Author: jeecg-boot
 * @Date:   2020-03-31
 * @Version: V1.0
 */
/**
 * @ClassName IStkIoBillService
 * @Description 
 * @author duany
 * @Date 2020-10-22 17:06:34
 * @version 1.0.0
 */
public interface IStkIoBillService extends IService<StkIoBill> {

	/**
	 * 添加一对多
	 * 
	 */
	public void saveMain(StkIoBill stkIoBill,List<StkIoBillEntry> stkIoBillEntryList) ;
	
	/**
	 * 修改一对多
	 * 
	 */
	public void updateMain(StkIoBill stkIoBill,List<StkIoBillEntry> stkIoBillEntryList);
	
	/**
	 * 删除一对多
	 */
	public void delMain (String id);
	
	/**
	 * 批量删除一对多
	 */
	public void delBatchMain (Collection<? extends Serializable> idList);

	IPage<StkIoBill> selectByStockIoType(IPage<StkIoBill> page, String stockIoType);
	void approve(String id);
	boolean isApproved(Integer year, Integer month);
	void createInBill(StkCheckBill stkCheckBill, List<StkCheckBillEntry> stkCheckBillEntryList);
	void createOutBill(StkCheckBill stkCheckBill, List<StkCheckBillEntry> stkCheckBillEntryList);
	
	/**
	 * @Description pda设备获取采购单
	 * @return
	 * Create at: 2020-09-18 15:57:14
	 * @author: duanyong
	 * Revision:
	 *    2020-09-18 15:57:14 - first revision by duanyong
	 *        
	 */
	List<StkIoBill> pdaGetPurchaseOrder();

	/**
	 * @Description 根据单号查询出入库单
	 * @param orderNum 单号
	 * @return
	 * Create at: 2020-10-21 13:45:09
	 * @author: duany
	 * Revision:
	 *    2020-10-21 13:45:09 - first revision by duany
	 *        
	 */
	public StkIoBill getByCode(String orderNum);
	
	/**
	 * @Description 根据销售单号查询销售单对应的销售入库单
	 * @param purchaseBillNo
	 * @return
	 * Create at: 2020-10-21 14:32:15
	 * @author: duany
	 * Revision:
	 *    2020-10-21 14:32:15 - first revision by duany
	 *        
	 */
	public List<StkIoBill> getPurchaseIoBill(String purchaseBillNo);

	public StkIoBill getSaleOutBill(String materialCode);
	
	
	/**
	 * @Description 更新实时库存
	 * @param stkIoBill
	 * @param stkIoBillEntryList
	 * Create at: 2020-10-22 17:06:37
	 * @author: duany
	 * Revision:
	 *    2020-10-22 17:06:37 - first revision by duany
	 *        
	 */
	public void updateInventory(StkIoBill stkIoBill, List<StkIoBillEntry> stkIoBillEntryList);

	public Result<?> getSaleOutBillList(Integer num);

	public StkIoBill getByMaterialId(String id);

	/**
	 * @Description 根据销售订单查询是否已经存在销售出库单
	 * @param orderCode
	 * @return
	 * Create at: 2020-11-03 13:14:43
	 * @author: duany
	 * Revision:
	 *    2020-11-03 13:14:43 - first revision by duany
	 *        
	 */
	public List<StkIoBill> getSaleOutBillBySourceCode(String orderCode);
	
	/**
	 * @Description 根据源单类型查询出入库信息
	 * @param sourceId
	 * @return
	 * Create at: 2021-01-27 13:57:46
	 * @author: duany
	 * Revision:
	 *    2021-01-27 13:57:46 - first revision by duany
	 *        
	 */
	public List<StkIoBill> getBillBySourceId(String sourceId);


	/**
	 * 查询当月的销售出货单
	 * @return
	 */
	public List<FreightOrIoBillVo> getBullBySell();
	/**
	 * 查询当月的采购购入单
	 * @return
	 */
	public List<FreightOrIoBillVo> getBullByBuy();


	/**
	 * 根据订单号查询订单信息
	 * @param billNo
	 * @return
	 */
	StkIoBill getBillByBillNo(String billNo);

	/**
	 * @Description 根据销售订单查询是否已经存在未打印的销售出库单
	 * @param orderCode
	 * @return
	 *
	 */
	public List<StkIoBill> getBillBySourceCode(String orderCode);

	/**
	* @Author: libaow
	* @Description: 根据销售单号获取信息
	* @DateTime: 15:13 2021/4/9
	* @Params: [orderNo]
	* @Return [java.lang.String]
	*/
	StkIoBill getBillByOrderNo(String orderNo);

	/**
	 * @Description 根据mes单编码和mes单ID查询出入库单
	 * @param mesIds
	 * @param mesCodes
	 * @return
	 * Create at: 2021-04-16 09:21:25
	 * @author: duany
	 * Revision:
	 *    2021-04-16 09:21:25 - first revision by duany
	 *        
	 */
	public List<StkIoBill> getBillByMes(List<String> mesIds, List<String> mesCodes);
	
	/**
	 * @Description 根据供应商查询采购过的物料，价格等
	 * @param stkIoBillVO
	 * @return
	 * Create at: 2021-05-05 11:50:35
	 * @author: xzs
	 * Revision:
	 *    2021-05-05 11:50:35 - first revision by xzs
	 *
	 */
	public List<StkPurchaseOrderDTO> querylistBySupplier(StkIoBillVO stkIoBillVO);
	
	/**
	 * @Description 采购单（供应商）列表汇总详情
	 * @param stkIoBillVO
	 * @return
	 * Create at: 2021-08-25 17:22:03
	 * @author: xzs
	 * Revision:
	 *    2021-08-25 17:22:03 - first revision by xzs
	 *
	 */
	public List<StkEntryDetailDTO> getEntryBySupplier(StkIoBillVO stkIoBillVO);
	
	/**
	 * @Description 商品分类毛利展示
	 * @param stkIoBillVO
	 * @return
	 * Create at: 2021-08-23 17:07:35
	 * @author: xzs
	 * Revision:
	 *    2021-08-23 17:07:35 - first revision by xzs
	 *
	 */
	public List<GrossProfitSummaryDTO> getGrossProfit(StkIoBillVO stkIoBillVO);
	
	/**
	 * @Description 商品详情毛利展示
	 * @param stkIoBillVO
	 * @return
	 * Create at: 2021-08-23 17:09:19
	 * @author: xzs
	 * Revision:
	 *    2021-08-23 17:09:19 - first revision by xzs
	 *
	 */
	public List<GrossProfitDetailDTO> getGrossProfitDetail(StkIoBillVO stkIoBillVO);
	
	/**
	 * @Description 客户商品毛利
	 * @param stkIoBillVO
	 * @return
	 * Create at: 2021-08-24 15:27:24
	 * @author: xzs
	 * Revision:
	 *    2021-08-24 15:27:24 - first revision by xzs
	 *
	 */
	public List<CustomerGrossProfitDTO> getCustomerGrossProfit(StkIoBillVO stkIoBillVO);
	
	/**
	 * @Description 客户购买商品毛利汇总详情
	 * @param stkIoBillVO
	 * @return
	 * Create at: 2021-08-25 10:28:18
	 * @author: xzs
	 * Revision:
	 *    2021-08-25 10:28:18 - first revision by xzs
	 *
	 */
	public List<CustomerGrossDetailDTO> getCustomerGrossProfitDetail(StkIoBillVO stkIoBillVO);

}
